
let instance;
export default class DragState {
  constructor() {
    if (instance) {
      return instance;
    }
    this.isDrag = false;
    this.startXPos = 0;
    this.prevOffsetLeft = 0;
    this.prevColWidth = 0;
    this.index = 0;
    this.dragItem = null
    instance = this;
  }
  setDragStart(ev, resizeBarInstance) {
    try {
      const { offsetLeft, index, colWidth } = resizeBarInstance.props
      this.isDrag = true;
      this.startXPos = ev.clientX;
      this.prevOffsetLeft = offsetLeft;
      this.prevColWidth = colWidth;
      this.index = index;
      this.dragItem = resizeBarInstance;
    } catch (err) {
      console.error(err) // eslint-disable-line
      throw new Error('the second argument should be the instance of ResizeBar')
    }
  }
  setDragEnd() {
    if (this.isDrag) {
      this.isDrag = false;
      this.startXPos = 0;
      this.prevOffsetLeft = 0;
      this.index = 0;
      this.dragItem = null
    }
  }
}
